In [1]:
import pandas as pd
import matplotlib.pyplot as plt
In [2]:
%matplotlib inline
In [3]:
import ext_datos as ext
import procesar as pro
import time_plot as tplt
In [4]:
dia1 = ext.extraer_data('dia1')
In [5]:
motoresdia1 = pro.procesar(dia1)
In [6]:
from scipy import integrate
import pandas as pd
import numpy as np
def integrate_method(self, how='trapz', unit='s'):
'''Numerically integrate the time series.
@param how: the method to use (trapz by default)
@return
Available methods:
* trapz - trapezoidal
* cumtrapz - cumulative trapezoidal
* simps - Simpson's rule
* romb - Romberger's rule
See http://docs.scipy.org/doc/scipy/reference/integrate.html for the method details.
or the source code
https://github.com/scipy/scipy/blob/master/scipy/integrate/quadrature.py
'''
available_rules = set(['trapz', 'cumtrapz', 'simps', 'romb'])
if how in available_rules:
rule = integrate.__getattribute__(how)
else:
print('Unsupported integration rule: %s' % (how))
print('Expecting one of these sample-based integration rules: %s' % (str(list(available_rules))))
raise AttributeError
result = rule(self.values, self.index.astype(np.int64) / 10**9)
#result = rule(self.values)
return result
pd.TimeSeries.integrate = integrate_method
In [7]:
motoresdia1['pot_m1'] = motoresdia1.busCurrent_m1*motoresdia1.busVoltage_m1
motoresdia1['pot_m2'] = motoresdia1.busCurrent_m2*motoresdia1.busVoltage_m2
In [8]:
motoresdia1['pot_total'] = motoresdia1.pot_m1+motoresdia1.pot_m2
In [49]:
motoresdia1.busCurrent_m1.plot()
motoresdia1.busCurrent_m2.plot()
Out[49]:
In [38]:
tplt.horam([motoresdia1.pot_m1,motoresdia1.pot_m2,motoresdia1.pot_total],'10:25','10:40')
In [23]:
motoresdia1[['motorRpm_m1','motorRpm_m1','pot_m1', 'pot_m2','pot_total']]['2014-11-13 12:00:00':'2014-11-13 12:15:00']
Out[23]:
In [26]:
motoresdia1.pot_total.dropna().integrate()/3600
Out[26]:
In [47]:
In [ ]: